package com.tudouji.project.product.controller;

import java.util.List;

import com.tudouji.project.system.domain.SysUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.product.domain.Innerprice;
import com.tudouji.project.product.service.IInnerpriceService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 内部价格Controller
 * 
 * @author wf
 * @date 2020-12-30
 */
@RestController
@RequestMapping("/product/innerprice")
public class InnerpriceController extends BaseController
{
    @Autowired
    private IInnerpriceService innerpriceService;


    @GetMapping("/importTemplate")
    public AjaxResult importTemplate()
    {
        ExcelUtil<Innerprice> util = new ExcelUtil<Innerprice>(Innerprice.class);
        return util.importTemplateExcel("内部价格数据");
    }


    /**
     * 查询内部价格列表
     */
    @PreAuthorize("@ss.hasPermi('product:innerprice:list')")
    @GetMapping("/list")
    public TableDataInfo list(Innerprice innerprice)
    {
        startPage();
        List<Innerprice> list = innerpriceService.selectInnerpriceList(innerprice);
        return getDataTable(list);
    }

    /**
     * 导出内部价格列表
     */
    @PreAuthorize("@ss.hasPermi('product:innerprice:export')")
    @Log(title = "内部价格", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Innerprice innerprice)
    {
        List<Innerprice> list = innerpriceService.selectInnerpriceList(innerprice);
        ExcelUtil<Innerprice> util = new ExcelUtil<Innerprice>(Innerprice.class);
        return util.exportExcel(list, "innerprice");
    }

    /**
     * 获取内部价格详细信息
     */
    @PreAuthorize("@ss.hasPermi('product:innerprice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(innerpriceService.selectInnerpriceById(id));
    }

    /**
     * 新增内部价格
     */
    @PreAuthorize("@ss.hasPermi('product:innerprice:add')")
    @Log(title = "内部价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Innerprice innerprice)
    {
        return innerpriceService.insertInnerprice(innerprice);
    }

    /**
     * 修改内部价格
     */
    @PreAuthorize("@ss.hasPermi('product:innerprice:edit')")
    @Log(title = "内部价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Innerprice innerprice)
    {

        return innerpriceService.updateInnerprice(innerprice);
    }

    /**
     * 删除内部价格
     */
    @PreAuthorize("@ss.hasPermi('product:innerprice:remove')")
    @Log(title = "内部价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(innerpriceService.deleteInnerpriceByIds(ids));
    }
}
